//
//  YXImage.h
//  YXImageBrowserDemo
//
//  Created by guo peng huang on 2021/5/18.
//


#if __has_include(<YYImage/YYImage.h>)
#import <YYImage/YYFrameImage.h>
#import <YYImage/YYSpriteSheetImage.h>
#import <YYImage/YYImageCoder.h>
#import <YYImage/YYAnimatedImageView.h>
#elif __has_include(<YYWebImage/YYImage.h>)
#import <YYWebImage/YYFrameImage.h>
#import <YYWebImage/YYSpriteSheetImage.h>
#import <YYWebImage/YYImageCoder.h>
#import <YYWebImage/YYAnimatedImageView.h>
#else
#import "YYFrameImage.h"
#import "YYSpriteSheetImage.h"
#import "YYImageCoder.h"
#import "YYAnimatedImageView.h"
#endif

NS_ASSUME_NONNULL_BEGIN

typedef BOOL(^YXImageDecodeDecision)(CGSize imageSize, CGFloat scale);


@interface YXImage : UIImage <YYAnimatedImage>

/** copy frome "YYImage" */

+ (nullable __kindof UIImage *)imageNamed:(NSString *)name; // no cache!
+ (nullable YXImage *)imageWithContentsOfFile:(NSString *)path;
+ (nullable YXImage *)imageWithData:(NSData *)data;
+ (nullable YXImage *)imageWithData:(NSData *)data scale:(CGFloat)scale;

/**
 If the image is created from data or file, then the value indicates the data type.
 */
@property (nonatomic, readonly) YYImageType animatedImageType;

/**
 If the image is created from animated image data (multi-frame GIF/APNG/WebP),
 this property stores the original image data.
 */
@property (nullable, nonatomic, readonly) NSData *animatedImageData;

/**
 The total memory usage (in bytes) if all frame images was loaded into memory.
 The value is 0 if the image is not created from a multi-frame image data.
 */
@property (nonatomic, readonly) NSUInteger animatedImageMemorySize;

/**
 Preload all frame image to memory.
 
 @discussion Set this property to `YES` will block the calling thread to decode
 all animation frame image to memory, set to `NO` will release the preloaded frames.
 If the image is shared by lots of image views (such as emoticon), preload all
 frames will reduce the CPU cost.
 
 See `animatedImageMemorySize` for memory cost.
 */
@property (nonatomic) BOOL preloadAllAnimatedImageFrames;

/// Expand methodes.
+ (nullable __kindof UIImage *)imageNamed:(NSString *)name decodeDecision:(nullable YXImageDecodeDecision)decodeDecision;
+ (nullable YXImage *)imageWithContentsOfFile:(NSString *)path decodeDecision:(nullable YXImageDecodeDecision)decodeDecision;
+ (nullable YXImage *)imageWithData:(NSData *)data decodeDecision:(nullable YXImageDecodeDecision)decodeDecision;
+ (nullable YXImage *)imageWithData:(NSData *)data scale:(CGFloat)scale decodeDecision:(nullable YXImageDecodeDecision)decodeDecision;

@end

NS_ASSUME_NONNULL_END
